package com.abc.service;

import com.abc.bean.Department;
import com.abc.bean.Patient;
import com.abc.mapper.DepartmentMapper;
import com.abc.mapper.PatientMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: bc
 * @Date: 2024-11-17 12:37
 * @Description:
 */
@Service
public class PatientService {
    @Autowired
    private PatientMapper patientMapper;
    public List<Patient> selectPatient(String patientName){
        return patientMapper.selectPatient(patientName);
    }
    public String addPatient(Patient patient){
        if(patientMapper.selectOnePatientByPatientId(patient.getPatientId())!=null){
            return "患者编号重复，添加失败";
        }
        return patientMapper.addPatient(patient) > 0 ? "添加成功" : "添加失败";
    }
    public int deletePatient(String id){
        return patientMapper.deletePatient(id);
    }
    public Patient selectOnePatientById(String id){
        return patientMapper.selectOnePatientById(id);
    }
    public int updatePatientById(Patient patient){
        System.out.println(patient);
        return patientMapper.updatePatientById(patient);
    }
}
